package com.csdj.questions.controller;


import com.csdj.questions.common.WebResult;
import com.csdj.questions.common.WebResultMsgCode;
import com.csdj.questions.entity.TTopic;
import com.csdj.questions.service.TTopicService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 话题表 前端控制器
 * </p>
 *
 * @author 郭成星
 * @since 2022-03-06
 */
@RestController
@RequestMapping("/t-topic")
public class TTopicController {
    @Resource
    private TTopicService tTopicService;

    /**
     * 根据话题内容进行模糊查询
     * @param topicText
     * @return
     */
    @GetMapping("/TopicLike")
    public WebResult TopicList(String topicText){
        List<TTopic> list = tTopicService.topicList(topicText);
        if(list != null){
            System.out.println(list);
            return new WebResult(WebResultMsgCode.SUCCESS).putData("TopicList",list);
        }
        return new WebResult(WebResultMsgCode.FAIL).putData("TopicList",false);
    }

}
